namespace TXLooker.WorkItemExtention.WIQL
{
    using System;
    using System.Globalization;

    public class NodeString : NodeItem
    {
        public NodeString(string s) : base(NodeType.String, s)
        {
        }

        public override bool CanCastTo(DataType type, CultureInfo culture)
        {
            switch (type)
            {
                case DataType.Numeric:
                    return ((base.Value.Length == 0) || Tools.IsNumericString(base.Value));

                case DataType.Date:
                    return ((base.Value.Length == 0) || Tools.IsDateString(base.Value, culture));

                case DataType.String:
                    return true;
            }
            return false;
        }

        public override string ToString()
        {
            return Tools.FormatString(base.Value);
        }

        public override string ConstStringValue
        {
            get
            {
                return base.Value;
            }
        }

        public override DataType DataType
        {
            get
            {
                return DataType.String;
            }
        }

        public override bool IsConst
        {
            get
            {
                return true;
            }
        }
    }
}

